package com.runa.persistence.repository;

import com.runa.persistence.entity.EntityThirdPart;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 2023/4/20 9:46
 * zhangYB
 */
public interface ThirdPartRepository extends JpaRepository<EntityThirdPart, Integer> {



    List<EntityThirdPart> findByCode(String code);


    @Query(nativeQuery = true, value = "select a.* from third_part a" +
            " left join actuator_equip b on a.id = b.equip_id and b.equip_type = 'THIRD_PART'" +
            " and b.actuator_id in (select anr.actuator from act_node_relation anr where anr.node = :node) " +
            " where b.id is null")
    List<EntityThirdPart> findNotUseInActuatorByNode(String node);



}
